﻿<%@ Page Language="C#" MasterPageFile="~/MasterPage/MasterPage.Master" AutoEventWireup="true" CodeBehind="BGM_RequestProject.aspx.cs" Inherits="KPIS.GERP.GBMS.APP_UI.BGM_RequestProject" %>
<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>

<%@ Register src="../Controls/Panel/UserPanel.ascx" tagname="UserPanel" tagprefix="uc3" %>
<%@ Register src="../Controls/Panel/BroadcastPanel.ascx" tagname="Broadcast" tagprefix="uc7" %>
<%@ Register src="../Controls/Combo/YearCombo.ascx" tagname="year" tagprefix="uc8" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">

<link rel="StyleSheet" href="../../Styles/StyleSheet.css" type="text/css">

<telerik:RadWindowManager 
    ID="RadWindowManager1" 
    ShowContentDuringLoad="false" 
    VisibleStatusbar="false" 
    ReloadOnShow="true" 
    runat="server" 
    Modal="true"
    KeepInScreenBounds="true" 
    Style="z-index: 7001">
    <Windows>
        <telerik:RadWindow 
            ID="ProjectDtls" 
            runat="server" 
            Width="1000px" 
            Height="590px"
            Behaviors="Reload, Close"
            OnClientClose="closeRadWindow" >
        </telerik:RadWindow>
        <telerik:RadWindow 
            ID="BIRequest" 
            runat="server" 
            Width="1000px" 
            Height="590px"
            Behaviors="Reload, Close"
            OnClientClose="closeRadWindow" >
        </telerik:RadWindow>
    </Windows>
</telerik:RadWindowManager>  

 <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
    <script type="text/javascript">

        function openProjectDetails() {
            var comboYear = $find('<%= ddlYear.ClientID %>');
            var comboJobSite = $find('<%= ddlJobSite.ClientID %>');
            if (comboJobSite.get_selectedIndex() != null && comboJobSite.get_selectedIndex() != 0) {
                var oWnd = radopen("BGM_Project.aspx?year=" + comboYear.get_value() + "&id=" + comboJobSite.get_value() + "&type=rq", "ProjectDtls");
            }
            else {
                alert("กรุณาระบุหน่วยงาน");
            }
        }
        
        function openBIRequest() {
            var comboYear = $find('<%= ddlYear.ClientID %>');
            var comboJobSite = $find('<%= ddlJobSite.ClientID %>');
            if (comboJobSite.get_selectedIndex() != null && comboJobSite.get_selectedIndex() != 0) {
                var oWnd = radopen("BI_BGM_Request.aspx?year=" + comboYear.get_value() + "&id=" + comboJobSite.get_value() + "&type=rq", "BIRequest");
            }
            else {
                alert("กรุณาระบุหน่วยงาน");
            }
        }

        function closeRadWindow(sender, args) {
            return false;
        }
        
        function onTextChange(sender) {
            if (sender.get_value() == "") {
                sender.set_text("");
            }
        } 

        var cancelDropDownClosing = false;
        function OnClientDropDownClosingHandler(sender, e) {
            e.set_cancel(cancelDropDownClosing);
        }
        function StopPropagation(e) {
            e.cancelBubble = true;
            if (e.stopPropagation) {
                e.stopPropagation();
            }
        }
    
    </script>
 </telerik:RadCodeBlock>


 <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" >
 </telerik:RadAjaxLoadingPanel>

<telerik:RadAjaxManager runat="server" ID="RadAjaxManager1" DefaultLoadingPanelID="RadAjaxLoadingPanel1">
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="ddlJobSite">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="panel2" LoadingPanelID="RadAjaxLoadingPanel1"/>
            </UpdatedControls>
        </telerik:AjaxSetting>
        <telerik:AjaxSetting AjaxControlID="ddlYear">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="panel2" LoadingPanelID="RadAjaxLoadingPanel1"/>
            </UpdatedControls>
        </telerik:AjaxSetting>
        <telerik:AjaxSetting AjaxControlID="gridProject">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="gridProjectByOption" LoadingPanelID="RadAjaxLoadingPanel1"/>
            </UpdatedControls>
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="gridSource" LoadingPanelID="RadAjaxLoadingPanel1"/>
            </UpdatedControls>
        </telerik:AjaxSetting>
   </AjaxSettings>
</telerik:RadAjaxManager>

<table style="width: 980px; height: 100%;">
<tr>
<%--<td width="274px" valign="top">
    <uc3:UserPanel ID="UserCtrl" runat="server" />
</td>--%>
<td valign="top">
    <uc7:Broadcast ID="BroadcastCtrl" runat="server" />
</td>
</tr>
<tr>
<td valign = "top" colspan="2">
    <div class="Background980">
    <div class="BackgroundBottom980">
            <asp:Panel ID="panelHeader" runat="server">
                <div class="header-grid">
                    <asp:Label ID="lblHeader" runat="server" Text="คำของบประมาณ"></asp:Label>
                </div>
            </asp:Panel>
            <asp:Panel ID="panel1" runat="server" Width="950px" Height="390px" ScrollBars="None">
            <table>
            <tr>
            <td valign="top" width="25%" style="border-right-style: groove; border-right-width: inherit; padding-right: 20px;">
                <ul class="formList">
                    <li>
                        <table>
                        <tr>
                            <td width="30%">
                                <asp:Label ID="Label1" runat="server" Text="ปี :"></asp:Label>
                            </td>
                        </tr>
                        <tr>
                            <td width="70%">
                                <telerik:RadComboBox ID="ddlYear" runat="server" Width="200px" 
                                    CssClass="textbox-string" 
                                    onselectedindexchanged="ddlYear_SelectedIndexChanged" AutoPostBack="True">
                                </telerik:RadComboBox>
                            </td>
                        </tr>
                        </table>     
                    </li>
                    <li>
                        <table>
                        <tr>
                            <td width="30%">
                                <asp:Label ID="Label2" runat="server" Text="หน่วยงาน :"></asp:Label>
                            </td>
                        </tr>
                        <tr>
                            <td width="70%">
                                <telerik:RadComboBox ID="ddlJobSite" runat="server" Visible="true" OnSelectedIndexChanged="ddlJobSite_SelectedIndexChanged"
                                    AllowCustomText="true" CausesValidation="false" DataTextField="text" AutoPostBack="true"
                                    DataValueField="value" EmptyMessage=" พิมพ์ที่นี่เพื่อค้นหาหน่วยงาน " 
                                    Filter="Contains" OnClientTextChange="onTextChange" Width="100%">
                                </telerik:RadComboBox>
                            </td>
                        </tr>
                        </table>     
                    </li>
<%--                    <li>
                        <table>
                        <tr>
                            <td width="50%">
                                <asp:Label ID="Label3" runat="server" Text="จำนวนโครงการ :"></asp:Label>
                            </td>
                            <td width="50%">

                            </td>
                        </tr>
                        </table>     
                    </li>
                    <li>
                        <table>
                        <tr>
                            <td width="50%">
                                <asp:Label ID="Label4" runat="server" Text="รวมทั้งหมด :"></asp:Label>
                            </td>
                            <td width="50%">

                            </td>
                        </tr>
                        </table>     
                    </li>
--%>                    <li>
                         <table>
                            <tr>
                                <td>
                                    <asp:Button ID="btnLoadProject" runat="server" Text="แสดงรายละเอียดโครงการ" 
                                        Width="200px" OnClientClick="openProjectDetails(); return false;"/>
                                </td>
                            </tr>
                        </table>
                    </li>
                    <li>
                        <table>
                            <tr>
                                <td>
                                    <asp:Button ID="btnExportExcel" runat="server" Text="Export to Excel" 
                                        Width="200px" onclick="btnExportExcel_Click" />
                                </td>
                            </tr>
                        </table>     
                    </li>
                    <li>
                        <table>
                            <tr>
                                <td>
                                    <asp:Button ID="btnBiRequest" runat="server" Text="แสดงกราฟ" 
                                        Width="200px" OnClientClick="openBIRequest(); return false;" />
                                </td>
                            </tr>
                        </table>     
                    </li>
                </ul>
            </td>
            <td align="left" valign="top" style="padding-left: 10px"  >
                <asp:Panel ID="panel2" runat="server" Height="330px" ScrollBars="Auto">
                <table cellpadding="0" cellspacing="0" width="98%">
                    <tr>
                        <td valign="top" width="50%" style="padding-top: 30px;" >
                            <telerik:RadGrid GroupingSettings-CaseSensitive="false" ID="gridProject" runat="server" OnSelectedIndexChanged="gridProject_SelectedIndexChanged"
                                AutoGenerateColumns="False" OnItemDataBound="gridProject_ItemDataBound" 
                                GridLines="None" MasterTableView-GridLines="None" ClientSettings-EnablePostBackOnRowClick="true"
                                Width="100%">
                                <mastertableview ShowFooter="true" ShowGroupFooter="true" NoMasterRecordsText="... ไม่มีข้อมูล ..." commanditemdisplay="none" width="100%" GroupLoadMode="Client" GroupsDefaultExpanded="false">                                                           
                                <Columns>
                                    <telerik:GridBoundColumn DataField="bgm_strat_list_seq" Visible="false"
                                        FilterControlWidth="100%" HeaderStyle-HorizontalAlign="Center" 
                                        HeaderText="รหัสกิจกรรมย่อย" ItemStyle-HorizontalAlign="Left" 
                                        UniqueName="bgm_strat_list_seq" >
                                        <HeaderStyle HorizontalAlign="Center" />
                                        <ItemStyle HorizontalAlign="Left" />
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn DataField="name"
                                        FilterControlWidth="100%" HeaderStyle-HorizontalAlign="Center" 
                                        HeaderText="กิจกรรมย่อย" ItemStyle-HorizontalAlign="Left" 
                                        UniqueName="name" >
                                        <HeaderStyle HorizontalAlign="Center" />
                                        <ItemStyle HorizontalAlign="Left" />
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn DataField="total_amount"
                                        Aggregate="Sum"
                                        FooterText="รวมทั้งหมด : "
                                        DataFormatString="{0:#,##0.00}"
                                        HeaderStyle-HorizontalAlign="Center"
                                        HeaderText="วงเงิน(บาท)"
                                        UniqueName="total_amount" Visible="true">
                                        <HeaderStyle HorizontalAlign="Center" Width="80px"/>
                                        <FooterStyle HorizontalAlign="Right" />
                                        <ItemStyle HorizontalAlign="Right" />
                                    </telerik:GridBoundColumn>
                                </Columns>
                                </mastertableview>
                                <clientsettings>
                                    <clientevents /><selecting allowrowselect="True" />
                                </clientsettings>
                            </telerik:RadGrid>
                            <br /><br />
                            <telerik:RadGrid GroupingSettings-CaseSensitive="false" ID="gridProjectByOption" runat="server"
                                AutoGenerateColumns="False" OnItemDataBound="gridProjectByOption_ItemDataBound"
                                GridLines="None" MasterTableView-GridLines="None" 
                                Width="100%">
                                <mastertableview ShowFooter="true" ShowGroupFooter="true" NoMasterRecordsText="... ไม่มีข้อมูล ..." commanditemdisplay="none" width="100%" GroupLoadMode="Client" GroupsDefaultExpanded="false">                                                           
                                <Columns>
                                    <telerik:GridBoundColumn DataField="name"
                                        FilterControlWidth="100%" HeaderStyle-HorizontalAlign="Center" 
                                        HeaderText="โครงการบูรณาการ" ItemStyle-HorizontalAlign="Left" 
                                        UniqueName="name" >
                                        <HeaderStyle HorizontalAlign="Center" />
                                        <ItemStyle HorizontalAlign="Left" />
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn DataField="total_amount"
                                        Aggregate="Sum"
                                        FooterText="รวมทั้งหมด : "
                                        DataFormatString="{0:#,##0.00}"
                                        HeaderStyle-HorizontalAlign="Center"
                                        HeaderText="วงเงิน(บาท)"
                                        UniqueName="total_amount" Visible="true">
                                        <HeaderStyle HorizontalAlign="Center" Width="80px"/>
                                        <FooterStyle HorizontalAlign="Right" />
                                        <ItemStyle HorizontalAlign="Right" />
                                    </telerik:GridBoundColumn>
                                </Columns>
                                </mastertableview>
                                <clientsettings>
                                    <clientevents />
                                </clientsettings>
                            </telerik:RadGrid>
                        </td>
                        <td valign="top" align="right" style="padding-left: 20px; padding-top: 30px;">
                            <telerik:RadGrid GroupingSettings-CaseSensitive="false" ID="gridSource" runat="server"
                                AutoGenerateColumns="False" OnItemDataBound="gridSource_ItemDataBound"
                                GridLines="None" MasterTableView-GridLines="None" 
                                Width="100%">
                                <mastertableview ShowFooter="true" NoMasterRecordsText="... ไม่มีข้อมูล ..." commanditemdisplay="none" datakeynames="bgm_source_seq" width="100%">                                                           
                                <Columns>
                                    <telerik:GridBoundColumn DataField="bgm_source_name"
                                        FilterControlWidth="100%" HeaderStyle-HorizontalAlign="Center" 
                                        HeaderText="แหล่งเงิน" ItemStyle-HorizontalAlign="Left" 
                                        UniqueName="bgm_source_name" >
                                        <HeaderStyle HorizontalAlign="Center" />
                                        <ItemStyle HorizontalAlign="Left" />
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn DataField="total_amount" 
                                        Aggregate="Sum"
                                        FooterAggregateFormatString="{0:#,##0.00}"
                                        DataFormatString="{0:#,##0.00}"
                                        HeaderStyle-HorizontalAlign="Center"
                                        HeaderText="วงเงิน(บาท)" 
                                        UniqueName="total_amount" Visible="true">
                                        <HeaderStyle HorizontalAlign="Center" Width="80px"/>
                                        <FooterStyle HorizontalAlign="Right" />
                                        <ItemStyle HorizontalAlign="Right" />
                                    </telerik:GridBoundColumn>
                                </Columns>
                                </mastertableview>
                                <clientsettings>
                                    <clientevents />
                                </clientsettings>
                            </telerik:RadGrid>
                            <br /><br />
                            <telerik:RadGrid GroupingSettings-CaseSensitive="false" ID="gridMarket" runat="server"
                                OnItemDataBound="gridMarket_ItemDataBound" 
                                AutoGenerateColumns="False" GridLines="None" MasterTableView-GridLines="None" 
                                Width="100%" Visible="false">
                                <mastertableview ShowFooter="true" NoMasterRecordsText="... ไม่มีข้อมูล ..." commanditemdisplay="none" datakeynames="bgm_option_seq" width="100%">                                                           
                                <Columns>
                                    <telerik:GridBoundColumn DataField="bgm_option_name"
                                        HeaderStyle-HorizontalAlign="Center" 
                                        HeaderText="ตลาด(ภูมิภาค/ประเทศ)" ItemStyle-HorizontalAlign="Left" 
                                        UniqueName="bgm_option_name">
                                        <HeaderStyle HorizontalAlign="Center" />
                                        <ItemStyle HorizontalAlign="Left" />
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn DataField="weight" HeaderStyle-Width="15%"
                                        Aggregate="Sum"
                                        FooterAggregateFormatString="{0:#,##0}"
                                        DataFormatString="{0:#,##0.000}"
                                        HeaderStyle-HorizontalAlign="Center" 
                                        HeaderText="น้ำหนัก" ItemStyle-HorizontalAlign="Right" 
                                        UniqueName="weight">
                                        <HeaderStyle HorizontalAlign="Center" />
                                        <FooterStyle HorizontalAlign="Right" />
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn DataField="total_amount" 
                                        Aggregate="Sum"
                                        FooterAggregateFormatString="{0:#,##0.00}"
                                        DataFormatString="{0:#,##0.00}"
                                        HeaderStyle-HorizontalAlign="Center"
                                        HeaderText="วงเงิน(บาท)" 
                                        UniqueName="total_amount" Visible="true">
                                        <HeaderStyle HorizontalAlign="Center" Width="80px"/>
                                        <FooterStyle HorizontalAlign="Right" />
                                        <ItemStyle HorizontalAlign="Right" />
                                    </telerik:GridBoundColumn>
                                </Columns>
                                </mastertableview>
                            </telerik:RadGrid>
                            <br /><br />
                            <telerik:RadGrid GroupingSettings-CaseSensitive="false" ID="gridProduct" runat="server"
                                OnItemDataBound="gridProduct_ItemDataBound" 
                                AutoGenerateColumns="False" GridLines="None" MasterTableView-GridLines="None" 
                                Width="100%" Visible="false">
                                <mastertableview ShowFooter="true" NoMasterRecordsText="... ไม่มีข้อมูล ..." commanditemdisplay="none" datakeynames="bgm_option_seq" width="100%">                                                           
                                <Columns>
                                    <telerik:GridBoundColumn DataField="bgm_option_name"
                                        HeaderStyle-HorizontalAlign="Center" 
                                        HeaderText="สินค้า/บริการ" ItemStyle-HorizontalAlign="Left" 
                                        UniqueName="bgm_option_name">
                                        <HeaderStyle HorizontalAlign="Center" />
                                        <ItemStyle HorizontalAlign="Left" />
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn DataField="weight" HeaderStyle-Width="15%"
                                        Aggregate="Sum"
                                        FooterAggregateFormatString="{0:#,##0}"
                                        DataFormatString="{0:#,##0.000}"
                                        HeaderStyle-HorizontalAlign="Center" 
                                        HeaderText="น้ำหนัก" ItemStyle-HorizontalAlign="Right" 
                                        UniqueName="weight">
                                        <HeaderStyle HorizontalAlign="Center" />
                                        <FooterStyle HorizontalAlign="Right" />
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn DataField="total_amount" 
                                        Aggregate="Sum"
                                        FooterAggregateFormatString="{0:#,##0.00}"
                                        DataFormatString="{0:#,##0.00}"
                                        HeaderStyle-HorizontalAlign="Center"
                                        HeaderText="วงเงิน(บาท)" 
                                        UniqueName="total_amount" Visible="true">
                                        <HeaderStyle HorizontalAlign="Center" Width="80px"/>
                                        <FooterStyle HorizontalAlign="Right" />
                                        <ItemStyle HorizontalAlign="Right" />
                                    </telerik:GridBoundColumn>
                                </Columns>
                                </mastertableview>
                            </telerik:RadGrid>                                                                                    
                        </td>
                    </tr>
                </table>
            </asp:Panel>
            <%--<asp:Panel ID="panel3" runat="server" Height="330px" ScrollBars="Auto">
                <uc1:BI_BGM_Request ID="BI_BGM_Request1" runat="server" />
            </asp:Panel>--%>
            </td>
            </tr>
            </table>
            </asp:Panel>
       </div>
    </div>
</td>
</tr>
</table>
<asp:DataGrid ID="grdExcel" runat="server"
    AutoGenerateColumns="true" Visible="false">
</asp:DataGrid>
</asp:Content>
